# -*- coding: utf-8 -*-

import warnings
from dramkit.gentools import catch_warnings, raise_warn, capture_print
from dramkit import simple_logger
logger = simple_logger()

@catch_warnings(logger)
def test_warn():
    # print('test warn...')
    raise_warn('TestWarn', 'test warn')

@catch_warnings(logger)
def test_warn0():
    # print('test warn0...')
    raise_warn('TestWarn', 'test warn', logger=logger)
    
@catch_warnings(logger, log_repeat=True)
def test_warn01():
    # print('test warn0...')
    raise_warn('TestWarn', 'test warn', logger=logger)
    
@catch_warnings()
def test_warn1(logger=None):
    raise_warn('TestWarn1', 'test warn1')
    
@catch_warnings(simple_logger(logname='test'))
@capture_print()
def test_warn2(logger=None):
    print('test_warn2...')
    
@catch_warnings(False)
def test_warn3(logger=None):
    print('test_warn3...')
    raise_warn('TestWarn3', 'test warn3')
    
@catch_warnings()
def test_warn4(logger=None):
    print('test_warn4...')
    warnings.warn('TestWarn4')
    
    
if __name__ == '__main__':
    test_warn()
    test_warn0()
    test_warn01()
    test_warn1(logger=simple_logger('./catch_warnings_test.log'))
    test_warn2(logger=simple_logger('./catch_warnings_test.log'))    
    test_warn3()
    test_warn4()
    
    
    
    
    
    
    
    